﻿#pragma once

#include <QWidget>
#include "ui_RePackingMp4ByFormatCodeWindow.h"
#include <thread>
#include <QString>
#include <QCloseEvent>
#include "../format/YDemuxer.h"
#include "../format/YMuxer.h"

class RePackingMp4ByFormatCodeWindow : public QWidget
{
	Q_OBJECT

public:
	RePackingMp4ByFormatCodeWindow(QWidget* parent = nullptr);
	~RePackingMp4ByFormatCodeWindow();
	void OnTransfer();

protected:
	// 重写关闭事件处理函数
	void closeEvent(QCloseEvent* event) override;

public slots:
	void OnSrcFileSelected();
	void OnDstOutputFileSelected();
	void OnStartTransfer();
private:
	Ui::RePackingMp4ByFormatCodeWindow ui;
	QString srcFilePath;
	QString dstFilePath;
	std::unique_ptr<std::thread> renderThread;
	bool isRunning = false;
	double begin_seconds = 0.0;//开始截取时间
	double end_seconds = 0.0;//结束截取时间
	long long begin_pts = 0;//开始pts
	long long begin_audio_pts = 0;//音频开始的pts
	long long end_pts = 0;//结束pts
	YDemuxer* demuxer = nullptr;
	YMuxer* muxer = nullptr;
};
